package com.internal.Login.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.HeadElement;
import com.google.gwt.dom.client.LinkElement;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.internal.SharedModule.client.Banner;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Login implements EntryPoint {
	public static VerticalPanel mainPanel;

	public void onModuleLoad() {
		injectThemeStyleSheet();
		Banner banner = new Banner();

		mainPanel = new VerticalPanel();
		mainPanel.setSize("100%", "100");

		mainPanel.add(banner);
		mainPanel.add(new LoginContent());

		RootPanel.get().add(mainPanel);
	}

	private native HeadElement getHeadElement() /*-{
		return $doc.getElementsByTagName("head")[0];
	}-*/;

	/**
	 * Inject the GWT theme style sheet based on the RTL direction of the
	 * current locale.
	 */
	private void injectThemeStyleSheet() {
		// Choose the name style sheet based on the locale.
		String styleSheet;
		styleSheet = "gwt/standard/standard_rtl.css";

		// Load the GWT theme style sheet
		String modulePath = GWT.getModuleBaseURL();
		LinkElement linkElem = Document.get().createLinkElement();
		linkElem.setRel("stylesheet");
		linkElem.setType("text/css");
		linkElem.setHref(modulePath + styleSheet);
		getHeadElement().appendChild(linkElem);
	}
}
